<html>
<head><meta charset="utf-8"><title>Patching rustc source tarball · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Patching.20rustc.20source.20tarball.html">Patching rustc source tarball</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="192300188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Patching%20rustc%20source%20tarball/near/192300188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Maurer <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Patching.20rustc.20source.20tarball.html#192300188">(Mar 30 2020 at 18:46)</a>:</h4>
<p>What's the right way to apply a patch to a vendored dependency in the rustc source tarball?<br>
If I directly modify it, I have to update the checksum file, which is fragile and will break every version.<br>
If I use a [patch] entry in Cargo.toml, it needs to regenerate the lockfile, and so frozen breaks it.</p>
<p>(The context is <a href="https://android.googlesource.com/toolchain/android_rust/+/refs/heads/master/patches/rustc-0005-Remove-special-cased-darwin-compiler-rt-support.patch" title="https://android.googlesource.com/toolchain/android_rust/+/refs/heads/master/patches/rustc-0005-Remove-special-cased-darwin-compiler-rt-support.patch">https://android.googlesource.com/toolchain/android_rust/+/refs/heads/master/patches/rustc-0005-Remove-special-cased-darwin-compiler-rt-support.patch</a> which probably doesn't make sense to actually upstream, since it is only needed due to a quirk of our build environment)</p>



<a name="192303249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Patching%20rustc%20source%20tarball/near/192303249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Patching.20rustc.20source.20tarball.html#192303249">(Mar 30 2020 at 19:08)</a>:</h4>
<p>If you add a <code>[patch]</code> entry in <code>Cargo.toml</code>, you can run <code>cargo fetch</code>. It is meant to download all dependencies from the internet when necessary, but it has the side effect of updating <code>Cargo.lock</code> for changes to <code>Cargo.toml</code>. It is a bit of a hack, but it should work.</p>



<a name="192317853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Patching%20rustc%20source%20tarball/near/192317853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Maurer <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Patching.20rustc.20source.20tarball.html#192317853">(Mar 30 2020 at 21:10)</a>:</h4>
<p>Ah yeah, so I can have a patch which adds a <code>[patch]</code> entry to <code>Cargo.toml</code>, then run <code>cargo fetch --offline</code> to fixup. This seems to almost work, but the <code>.cargo/config</code> that replaces crates-io with a vendored copy only appears during the execution of <code>bootstrap.py</code>, and without it cargo fetch will attempt to actually fetch sources and fail.</p>
<p>I can work around this in my build script by running <code>x.py --help</code>, <em>expecting</em> failure, and then running <code>cargo fetch --offline</code>, but this does seem a little icky. I don't see any user facing way to trigger the <code>.cargo/config</code> generation otherwise though</p>



<a name="192320616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Patching%20rustc%20source%20tarball/near/192320616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Patching.20rustc.20source.20tarball.html#192320616">(Mar 30 2020 at 21:37)</a>:</h4>
<p>In Fedora, I just clear the files list in <code>.cargo-checksum.json</code>. An empty list always passes validation. :)</p>



<a name="192320621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Patching%20rustc%20source%20tarball/near/192320621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Patching.20rustc.20source.20tarball.html#192320621">(Mar 30 2020 at 21:37)</a>:</h4>
<p>e.g. <a href="https://src.fedoraproject.org/rpms/rust/blob/3d7a297b89c75d8f59c13af52f6cdaf26785172f/f/rust.spec#_457" title="https://src.fedoraproject.org/rpms/rust/blob/3d7a297b89c75d8f59c13af52f6cdaf26785172f/f/rust.spec#_457">https://src.fedoraproject.org/rpms/rust/blob/3d7a297b89c75d8f59c13af52f6cdaf26785172f/f/rust.spec#_457</a></p>



<a name="192321345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Patching%20rustc%20source%20tarball/near/192321345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Maurer <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Patching.20rustc.20source.20tarball.html#192321345">(Mar 30 2020 at 21:45)</a>:</h4>
<p><span class="user-mention" data-user-id="138448">@cuviper</span> I think I like the patch approach a little better anyways, since it might allow us to add incremental support to our presubmit checks for this project someday, but I'll keep it in mind, thanks.</p>



<a name="192400106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Patching%20rustc%20source%20tarball/near/192400106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Patching.20rustc.20source.20tarball.html#192400106">(Mar 31 2020 at 14:52)</a>:</h4>
<p><span class="user-mention" data-user-id="138448">@cuviper</span> Debian nukes the checksum file as well, for the same reason.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>